package cn.tedu.charging.order.controller;


import cn.tedu.charging.common.pojo.param.OrderAddParam;
import cn.tedu.charging.common.protocol.JsonResult;
import cn.tedu.charging.order.producer.OrderEmqxProducer;
import cn.tedu.charging.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RestController
@Slf4j
@Api(tags = "订单模块")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @Autowired
    private OrderEmqxProducer producer;
    @ApiOperation(value="创建订单")
    @PostMapping("/order/create")
    public JsonResult<String> createOrder(@RequestBody OrderAddParam param){
        String orderNo=orderService.createOrder(param);
         UUID.randomUUID().toString().replace("-", "");
        return JsonResult.ok(orderNo);
    }
    @GetMapping("/send")
    public JsonResult sendMsg(){
        producer.sendMessage("/aaa","你好");
        return JsonResult.ok("ok");
    }
}
